package com.kuang.annotation;

public class Test03 {
    public static void main(String[] args) throws ClassNotFoundException {
        Person person = new Student();
        System.out.println(person);
/**
* //获取Class对象
* //方式一
* 通过对象获得
*/
        //方式一:通过对象获得
        Class c1 = person.getClass();
        //方式二:通过forName来获得
        Class c2 = Class.forName("com.kuang.annotation.Student");
        //方式三:通过类名.class;
        Class c3 = Student.class;
        System.out.println(c1.hashCode());
        System.out.println(c2.hashCode());
        System.out.println(c3.hashCode());

        //基本内置类型都有包装类都有一个Type属性
        Class<Integer> c4 = Integer.TYPE;
        System.out.println(c4);

        //获得父类类型
        Class c5 = c3.getSuperclass();
        System.out.println(c5);
    }
}
class Person{
     private String name;
    int age;
    int id;

    public Person() {

    }

    private void test(){

    }
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

//    public Person() {
//    }

    public Person(String name, int age, int id) {
        this.name = name;
        this.age = age;
        this.id = id;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", id=" + id +
                '}';
    }
}
class Student extends Person{
    public Student() {
        super();
        this.setName("学生");
    }
}
class Teacher extends Person{
    public Teacher() {
        super();
        this.setName("教师");
    }
}